import { fetchProduct} from "@/spi/gwc";
export default {
    namespaced: true,
    state:{
        tag:"产品模块store",
        products:[]
    },
    mutations: {
        SET_PRODUCT(state,payload){
            console.log(state);
            state.products = payload;
        },
        DECREMNT_INVENTORY(state,payload){
            console.log(payload);
            let target=state.products.find(item=>item.id===payload)
            if(target){
              target.inventory--  
        }
     }
    },
    actions:{
     async FETCH_PRODUCT(context,payload){
        let res = await fetchProduct();
        console.log(res);
        context.commit('SET_PRODUCT',res.data)
     }
    },
    getters:{},
    // modules:{},
}